package cn.zjnu.struts;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import cn.zjnu.DAO.Dao;
import cn.zjnu.DAO.RoomDAO;
import cn.zjnu.bean.Rooms;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class RoomAction extends ActionSupport{
	private String BuildNo=null;
	private String DeptId=null;
	private String EmId=null;
	RoomDAO Room=new RoomDAO();
	public String getBuildNo() {
		return BuildNo;
	}
	public void setBuildNo(String buildNo) {
		BuildNo = buildNo;
	}
	public String getDeptId() {
		return DeptId;
	}
	public void setDeptId(String deptId) {
		DeptId = deptId;
	}
	public String getEmId() {
		return EmId;
	}
	public void setEmId(String emId) {
		EmId = emId;
	}
	public String execute() throws ClassNotFoundException, SQLException{
		Room.connect();
		ResultSet rs=Room.Query(EmId, DeptId, BuildNo);
		List rooms= new ArrayList<Rooms>();
		while(rs.next()){
			String RoomId,BuildId,RoomNo,UseArea,BuildArea,State,EmId,DeptId,SubDeptId,ThreeDeptId,RoomType,Memo;
			RoomId=rs.getString(1);
			BuildId=rs.getString(2);
		    RoomNo=rs.getString(3);
			UseArea=rs.getString(4);
			BuildArea=rs.getString(5);
			State=rs.getString(6);
			EmId=rs.getString(7);
			DeptId=rs.getString(8);
			SubDeptId=rs.getString(9);
			ThreeDeptId=rs.getString(10);
			RoomType=rs.getString(11);
			Memo=rs.getString(12);
			Rooms room=new Rooms(RoomId, BuildId, RoomNo, UseArea, BuildArea, State, EmId, DeptId, SubDeptId, ThreeDeptId, RoomType, Memo);
			rooms.add(room);
		}
		ActionContext ct=ActionContext.getContext();
		ct.put("rooms", rooms);
		return this.SUCCESS;
	}
}
